#include <stdio.h>
#include <string.h>
int main()
{
    int var;
    int count = 0;
    int num = 0;
    printf("请输入一个正整数：");
    scanf("%d", &var);
    int var1 = var;
#if 0
    scanf("%s", &ch);
    //int ret = strlen(ch);错的，为啥
    int size = strlen(&ch);
    printf("size:%d\n", size);
    (int *)ch;
    printf("size:%d\n", ch);
    // for(int idx = 0; idx < size; idx++)
    //我试图把字符串转化为整数
 #endif
 /* 获取数字长度 */
    while(var != 0)
    {
        var /= 10;
        count++;
    }
    int len = count ;
    printf("len:%d\n", len);

    for(int idx = 0; idx < len; idx++)
    {
        num += var1 % 10;
        var1 /= 10;
    }
    printf("average:%d\n", num);//num的值没有赋进去？为啥
    double average = num / len;
    printf("average:%f\n", average);
    return 0;
}

